package ch.ethz.smseth;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.net.Uri;

public class SmsStore
{
	ContentResolver _resolver;
	
	public SmsStore(ContentResolver resolver)
	{
		_resolver = resolver;
	}
	
	public void insertSent(String dest, String message)
	{
		long time = java.lang.System.currentTimeMillis();
		ContentValues values = new ContentValues();
		values.put("address", dest);
		values.put("date", Long.toString(time));
		values.put("read", 1);
		values.put("status", -1);
		values.put("type", 2 /* sent */);
		values.put("body", message);

		_resolver.insert(Uri.parse("content://sms"), values);
	}
	
	public Uri insertDraft(String dest, String message)
	{
		long time = java.lang.System.currentTimeMillis();
		ContentValues values = new ContentValues();
		values.put("address", dest);
		values.put("date", Long.toString(time));
		values.put("read", 1);
		values.put("status", -1);
		values.put("type", 3 /* draft */);
		values.put("body", message);

		return _resolver.insert(Uri.parse("content://sms"), values);
	}
}
